package au.com.evoCoach.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import au.com.evoCoach.domain.Team;
import au.com.evoCoach.domain.TeamPlayer;

@Repository
public class TeamPlayerDAO extends BaseDAO {

	public TeamPlayerDAO() {
		super(TeamPlayer.class);
	}
	
	public List<TeamPlayer> getTeamPlayers(Team team, boolean includeRookies) {
	 	String sql = "from TeamPlayer where team = :team";
	 	if (!includeRookies) {
	 	    sql += " and rookieStatus is null";
	 	}
       	Query query = getSession().createQuery(sql);
       	query.setParameter("team", team);
       	
       	return query.list();		
	}
	
	public List<TeamPlayer> getAllTeamPlayers() {
		String sql = "from TeamPlayer";
       	Query query = getSession().createQuery(sql);
      	return query.list();
		
	}
}
